package com.huaguoguo.cyg.spider.pipeline;

import sun.management.counter.perf.PerfInstrumentation;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 类说明： <br/>
 * author:huaguoguo
 * Date: 2019/8/18
 * Time: 21:43
 */
public abstract class BasePipeline implements Pipeline {

    /**
     * 可以用来页面参数什么的
     */
    private Map<String, Object> attrs = new LinkedHashMap();

    /**
     * 追加参数进pipeline
     * @param key
     * @param value
     */
    public void putAttr(String key, Object value){
        this.attrs.put(key, value);
    }

    /**
     * 取参数
     * @param key
     * @param <T>
     * @return
     */
    public <T> T get(String key) {
        Object o = this.attrs.get(key);
        if (o == null) {
            return null;
        }
        return (T) o;
    }

}
